home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1997 March / macformat-048.iso / Shareware Plus / Updaters / NewsWatcher 2.15+jp1 folder / patch source CW10 / patch.note < prev    next >
Encoding:
Text File  |  1996-12-16  |  13.5 KB  |  520 lines  |  [TEXT/CWIE]

  1. //    Patch note for NewsWatcher 2.XX+jp1
  2. //    Copyright (C) 1994-1996 Mizutori Tetsuya
  3. //    NewsWatcher 2.0d17+jp1,    1994/ 5/24
  4. //    NewsWatcher 2.0b5+jp1,    1994/ 9/15
  5. //    NewsWatcher 2.0b13+jp1,    1994/10/22
  6. //    NewsWatcher 2.0b24+jp1,    1995/ 1/15
  7. //    NewsWatcher 2.0b24+jp2,    1995/ 2/ 8
  8. //    NewsWatcher 2.0b24+jp3,    1995/ 2/22
  9. //    NewsWatcher 2.0+jp1,    1995/ 7/14
  10. //    NewsWatcher 2.11+jp1,    1995/11/30
  11. //    NewsWatcher 2.12+jp1,    1996/ 2/12
  12. //    NewsWatcher 2.13+jp1,    1996/ 6/ 6
  13. //    NewsWatcher 2.13+jp2,    1996/ 6/20
  14. //    NewsWatcher 2.13+jp3,    1996/ 8/27
  15. //    NewsWatcher 2.14+jp1,    1996/11/24
  16. //    NewsWatcher 2.15+jp1,    1996/12/16
  17. //
  18.  
  19. /*
  20.     The patch provides the following functions.
  21.  
  22.     (0) Common toolbox for the patch works. in 'myTools.{h,c}'
  23.         The summary of contents is listed below.
  24.  
  25.     (1) Kanji code conversion
  26.         In most Japanese news system, the articles and mail messages
  27.     are (must be) coded in JIS Kanji code system. Whereas Macintosh
  28.     system takes the Shift-JIS Kanji code system. So, the Kanji code
  29.     conversion is required in two ways like this:
  30.       NNTP server -> Macintosh:  - related: 'net.c::MungeIn()'
  31.       Macintosh -> NNTP or SMTP: - related: 'net.c::MungeOut()'
  32.       NNTP server -> Mac files:  - related: 'news.c::CopyArticleToFile...()'
  33.  
  34.     (2) Kill Latin1 conversions
  35.         For the technical difficulties and my wish to minimize the
  36.     patch, I have decided to rather kill the Latin-1 conversion than
  37.     to live together with 8-bit Kanji and non-US characters.
  38.       Kill Latin1 conversions:   - related: 'charset.c::...()'
  39.  
  40.     (3) Wrap/UnWrap paragraphs including Kanji characters
  41.         I have changed my mind to add Wrap/UnWrap to the patch.
  42.         On wrapping the paragraphs, the potential break points are
  43.     now at the boundaries of roman-words (originally), or any
  44.     position in the Kanji-strings.
  45.         On UnWrapping the paragraphs, the separate lines are
  46.     concatinated with one blank character for the adjacent roman-
  47.     words (originally), or no blanks for Kanji-strings.
  48.       Wrap:   - related: 'send.c::Wrap(), SendMessage()',
  49.                            'message.c::DoWrap(), InsertText()'
  50.       UnWrap: - related: 'send.c::UnWrap()',
  51.                            'message.c::DoUnwrap()'
  52. */
  53.  
  54.  
  55.  
  56. /*********************/
  57. /***** myTools.h *****/
  58. /*********************/
  59. -- all new ! ( a summary )
  60. #define MZTR_PATCH        1
  61.  
  62. #define if_COUNT_MS_KANJI(n,p,pEnd)
  63. #define if_MS_KANJI(p,q,pEnd)
  64. #define if_JIS_KANJI(p,q,pEnd)
  65. #define if_JIS_KANJI_CHUNK(p,t,tLen,c,gFileLinePos)
  66.  
  67.  
  68.  
  69. /*********************/
  70. /***** myTools.c *****/
  71. /*********************/
  72. -- all new ! ( a summary )
  73. /**** Kanji code conversion *****/
  74. Boolean IsJISKanji    ( const char * p, const char * pEnd );
  75. Boolean IsMSKanji    ( const char * p, const char * pEnd );
  76. Boolean IsEUCKanji  ( const char * p, const char * pEnd );
  77.  
  78. void EUCKanji2JIS    ( const char * p, char * q );
  79. void JIS2EUCKanji    ( const char * p, char * q );
  80. void MSKanji2JIS    ( const char * p, char * q );
  81. void JIS2MSKanji    ( const char * p, char * q );
  82.  
  83. Boolean IsKanji        ( const char * p, const char * pStart, const char * pEnd );
  84. long SkipOnBrace    ( const char * p, const char * pStart, const char * pEnd );
  85.  
  86. OSErr MyResizeHandle    ( void * handle, Size len );
  87.  
  88. long GetFillColumn    ( void );
  89.  
  90. Boolean KillCustomMessageID    ( void );
  91.  
  92.  
  93. /******************/
  94. /***** net.c *****/
  95. /******************/
  96.  
  97. -- line 143 (near)
  98. #include "myTools.h"    /* Mizutori */
  99.  
  100.  
  101. -- line 1269 (near) in MungeOut()
  102. #ifdef MZTR_PATCH    /* Mizutori */
  103.  
  104. /* First, count the SJIS Kanji sequences */
  105.     p = *text;
  106.     pEnd = p + textLen;
  107.     oldTextLen = textLen;
  108.  
  109.     while ( p < pEnd )
  110.         if_COUNT_MS_KANJI(textLen,p,pEnd)
  111.         else p++;
  112.  
  113.     if ( textLen == oldTextLen ) return noErr;    /* including no Kanji */
  114.  
  115. /* Second, resize the text size and shift the text strings forward */
  116.     err = MySetHandleSize(text, textLen);
  117.     if (err != noErr) return err;
  118.     BlockMoveData(*text,*text+textLen-oldTextLen,oldTextLen);
  119.  
  120. /* Third, convert Kanji code, SJIS -> JIS */
  121.     q = *text;
  122.     p = q + (textLen - oldTextLen);
  123.     pEnd = p + oldTextLen;
  124.     while ( p < pEnd )
  125.         if_MS_KANJI(p,q,pEnd)
  126.         else *q++ = *p++;
  127.  
  128. #endif /* MZTR_PATCH */
  129.     return noErr;
  130.  
  131.  
  132. -- line 1334 (near) in MungeIn()
  133.     if (mungePeriods) {
  134.         while (p < pEnd) {
  135.             if (*p == '.' && *(p+1) == '.') {
  136.                 *q++ = '.';
  137.                 p += 2;
  138.             }
  139. #ifdef MZTR_PATCH    /* Mizutori */
  140.             while (p < pEnd && (*p != CR || *(p+1) != LF))
  141.                 if_JIS_MIME(p,q,pEnd)
  142.                 else
  143.                 if_JIS_KANJI(p,q,pEnd)
  144.                 else *q++ = *p++;
  145. #else /* MZTR_PATCH */
  146.             while (p < pEnd && (*p != CR || *(p+1) != LF)) *q++ = *p++;
  147. #endif /* MZTR_PATCH */
  148.             *q++ = CR;
  149.             p += 2;
  150.         }
  151.     } else {
  152.         while (p < pEnd) {
  153. #ifdef MZTR_PATCH    /* Mizutori */
  154.             if_JIS_MIME(p,q,pEnd)
  155.             else
  156.             if_JIS_KANJI(p,q,pEnd)
  157.             else
  158. #endif /* MZTR_PATCH */
  159.             if (*p == CR && *(p+1) == LF) {
  160.                 *q++ = CR;
  161.                 p += 2;
  162.             } else {
  163.                 *q++ = *p++;
  164.             }
  165.         }
  166.     }
  167.  
  168.  
  169.  
  170. /******************/
  171. /***** news.c *****/
  172. /******************/
  173.  
  174. -- line 33 (near)
  175. #include "myTools.h"    /* Mizutori */
  176.  
  177.  
  178. -- line 619 (near) in CopyArticleToFileChunkFunction()
  179. #ifdef MZTR_PATCH    /* Mizutori */
  180.     static Boolean    gInKanjiSequence = false;
  181.     static Boolean    gEscapeKanjiIn  = false;
  182.     static Boolean    gEscapeKanjiOut = false;
  183.     static Ptr        gMimeStart = nil;
  184. #endif /* MZTR_PATCH */
  185.  
  186.  
  187. -- line 675 (near) in CopyArticleToFileChunkFunction()
  188. #ifdef MZTR_PATCH    /* Mizutori */
  189.         } else if_JIS_MIME_CHUNK(p,t,tLen,c,x->fileLinePos)
  190.           else if_JIS_KANJI_CHUNK(p,t,tLen,c,x->fileLinePos)
  191.           else if (c >= ' ' || c == CR || c == FF || c < 0 || c==ESC) {
  192. #else /* MZTR_PATCH */
  193.         } else if (c >= ' ' || c == CR || c == FF || c < 0) {
  194. #endif /* MZTR_PATCH */
  195.  
  196.  
  197.  
  198. /******************/
  199. /**** charset.c ***/
  200. /******************/
  201.  
  202. -- line 20 (near)
  203. #include "myTools.h"    /* Mizutori */
  204.  
  205.  
  206. -- line 53 (near) in MapLatin1ToMacPtr()
  207. #ifdef MZTR_PATCH    /* Mizutori */
  208.     return false;
  209. #endif /* MZTR_PATCH */
  210.  
  211.  
  212. -- line 120 (near) in MapLatin1ToMacStr()
  213. #ifdef MZTR_PATCH    /* Mizutori */
  214.         *q = *p;
  215. #else /* MZTR_PATCH */
  216.         *q = table[*p];
  217. #endif /* MZTR_PATCH */
  218.  
  219.  
  220. -- line 149 (near) in MapMacToLatin1Ptr()
  221. #ifdef MZTR_PATCH    /* Mizutori */
  222.     return false;
  223. #endif /* MZTR_PATCH */
  224.  
  225.  
  226. /***** patch for sorting Kanji Subject *****/
  227.  
  228. /********************/
  229. /***** thread.c *****/
  230. /********************/
  231.  
  232. -- line 25 (near)
  233. #include "myTools.h"    /* Mizutori */
  234.  
  235.  
  236. -- line 267 (near) in InitSortInfo()
  237.         while (*x != 0) {
  238. #ifdef MZTR_PATCH    /* Mizutori */
  239.             if ( IsKanji(x,x,x+2) )  {
  240.                 *canon++ = *x++;
  241.                 *canon++ = *x++;
  242.             } else
  243. #endif /* MZTR_PATCH */
  244.  
  245.  
  246.  
  247. /***** patch for No Extra space around Kanji strings *****/
  248.  
  249. /********************/
  250. /***** teutil.c *****/
  251. /********************/
  252.  
  253. -- line 19 (near)
  254. #include "myTools.h"    /* Mizutori */
  255.  
  256.  
  257. -- line 180 (near) in IsWordStart()
  258. #ifdef MZTR_PATCH    /* Mizutori */
  259.     if ( IsKanji(str+offset,str,str+len) )  return false;
  260. #endif /* MZTR_PATCH */
  261.  
  262.  
  263. -- line 212 (near) in IsWordEnd()
  264. #ifdef MZTR_PATCH    /* Mizutori */
  265.     if ( IsKanji(str+offset-2,str,str+len) )  return false;
  266. #endif /* MZTR_PATCH */
  267.  
  268.  
  269.  
  270. /***** patch for Wrap/UnWrap paragraphs *****/
  271.  
  272. /******************/
  273. /***** send.h *****/
  274. /******************/
  275. //    void Wrap (Handle text, long start, long end);
  276. //    void UnWrap (Handle text, long start, long end);
  277. long Wrap (Handle text, long start, long end);        /* Mizutori */
  278. long UnWrap (Handle text, long start, long end);    /* Mizutori */
  279.  
  280.  
  281. /******************/
  282. /***** send.c *****/
  283. /******************/
  284.  
  285. -- line 28 (near)
  286. #include "myTools.h"    /* Mizutori */
  287.  
  288.  
  289. -- line 48 (near) in Wrap()
  290. #ifdef MZTR_PATCH    /* Mizutori */
  291. long Wrap (Handle text, long start, long end)
  292. #else /* MZTR_PATCH */
  293. void Wrap (Handle text, long start, long end)
  294. #endif /* MZTR_PATCH */
  295. {
  296.     char *p, *pEnd, *q, *lastSpace;
  297. #ifdef MZTR_PATCH    /* Mizutori */
  298.     long    gFillColumn = GetFillColumn();    // typically 74
  299. #endif /* MZTR_PATCH */
  300.  
  301.     p = *text + start;
  302.     pEnd = *text + end;
  303.     while (p < pEnd) {
  304.         q = p;
  305.         while (q < pEnd && *q != CR) q++;
  306. #ifdef MZTR_PATCH    /* Mizutori */
  307.         if (q - p > gFillColumn+6) {
  308. #else /* MZTR_PATCH */
  309.         if (q - p > 80) {
  310. #endif /* MZTR_PATCH */
  311.             q = p;
  312.             lastSpace = 0;
  313.             while (true) {
  314. #ifdef MZTR_PATCH    /* Mizutori */
  315.                 if ( IsKanji(q,*text+start,pEnd) ) {
  316.                     long    k;
  317.                     q++;
  318.                     while ( (k=SkipOnBrace(q+1,*text+start,pEnd)) > 0 ) q += k;
  319.                     while ((q+1) < pEnd && *(q+1) == ' ') q++;
  320.                     if (lastSpace != 0 && lastSpace - p <= (gFillColumn-2) && q - p >= (gFillColumn+1)) lastSpace = q;
  321. //                    if (lastSpace != 0 && lastSpace - p <= 72 && q - p >= 75) lastSpace = q;
  322.                 } else {
  323.                     while (q < pEnd && *q != ' ' && *q != CR && !IsKanji(q,*text+start,pEnd)) q++;
  324.                     if ( IsKanji(q,*text+start,pEnd) ) q--;
  325.                 }
  326. #else /* MZTR_PATCH */
  327.                 while (q < pEnd && *q != ' ' && *q != CR) q++;
  328. #endif /* MZTR_PATCH */
  329.                 if (q < pEnd && *q == ' ') {
  330.                     while (q < pEnd && *q == ' ') q++;
  331.                     q--;
  332.                 }
  333. #ifdef MZTR_PATCH    /* Mizutori */
  334.                 if (q - p >= (gFillColumn+1) && lastSpace != 0) {
  335. #else /* MZTR_PATCH */
  336.                 if (q - p >= 75 && lastSpace != 0) {
  337. #endif /* MZTR_PATCH */
  338. #ifdef MZTR_PATCH    /* Mizutori */
  339.                     lastSpace++;
  340.                     if ( *lastSpace != CR ) {
  341.                         long pX, pEndX, qX, lastSpaceX;
  342.                         long len = MyGetHandleSize(text);
  343.                         pX = p - *text; pEndX = pEnd - *text; qX = q - *text; lastSpaceX = lastSpace - *text;
  344.                         MyResizeHandle(text, len+1);
  345.                         p = *text + pX; pEnd = *text + pEndX; q = *text + qX; lastSpace = *text + lastSpaceX;
  346.                         BlockMoveData(lastSpace,lastSpace+1,len - (lastSpace - *text));
  347.                         q++; // q = lastSpace + 1;
  348.                         pEnd++;
  349.                     }
  350. #endif /* MZTR_PATCH */
  351.                     *lastSpace = CR;
  352.                     p = lastSpace + 1;
  353.                     lastSpace = 0;
  354.                 }
  355.                 if (q >= pEnd || *q == CR) break;
  356.                 lastSpace = q;
  357.                 q++;
  358.             }
  359.         }
  360.         p = q+1;
  361.     }
  362. #ifdef MZTR_PATCH    /* Mizutori */
  363.     return (long) ( pEnd - *text - end );
  364. #endif /* MZTR_PATCH */
  365. }
  366.  
  367.  
  368. -- line 137 (near) in UnWrap()
  369. #ifdef MZTR_PATCH    /* Mizutori */
  370. long UnWrap (Handle text, long start, long end)
  371. #else /* MZTR_PATCH */
  372. void UnWrap (Handle text, long start, long end)
  373. #endif /* MZTR_PATCH */
  374. {
  375.     char *p, *pEnd;
  376.  
  377.     p = *text + start;
  378.     pEnd = *text + end;
  379.     while (p < pEnd) {
  380.         while (p < pEnd && *p != CR) p++;
  381.         p++;
  382.         if (p < pEnd) {
  383.             if (*p == ' ' || *p == '\t') continue;
  384.             if (*p == CR) {
  385.                 while (p < pEnd && *p == CR) p++;
  386.                 continue;
  387.             }
  388. #ifdef MZTR_PATCH    /* Mizutori */
  389.             if ( *(p-2) == ' ' || *(p-2) == '\t' ||
  390.                 ( IsKanji(p-3,*text+start,pEnd) || IsKanji(p,*text+start,pEnd) ) ) {
  391. //                ( IsKanji(p-3,*text+start,pEnd) && IsKanji(p,*text+start,pEnd) ) ) {
  392.                 long pX, pEndX;
  393.                 long len = MyGetHandleSize(text);
  394.                 BlockMoveData(p,p-1,len - (p - *text));
  395.                 pX = p - *text; pEndX = pEnd - *text;
  396.                 MyResizeHandle(text, len-1);
  397.                 p = *text + pX; pEnd = *text + pEndX;
  398.                 pEnd--;
  399.             } else
  400.                 *(p-1) = ' ';
  401. #else /* MZTR_PATCH */
  402.             *(p-1) = ' ';
  403. #endif /* MZTR_PATCH */
  404.         }
  405.     }
  406. #ifdef MZTR_PATCH    /* Mizutori */
  407.     return - (long) ( *text + end - pEnd );
  408. #endif /* MZTR_PATCH */
  409. }
  410.  
  411.  
  412. -- line 742 (near) in SendMessage()
  413. #ifdef MZTR_PATCH    /* Mizutori */
  414.     if ((**info).wrapOnSend) textLen += Wrap(text, 0, textLen);
  415. #else /* MZTR_PATCH */
  416.     if ((**info).wrapOnSend) Wrap(text, 0, textLen);
  417. #endif /* MZTR_PATCH */
  418.  
  419.  
  420. /*********************/
  421. /***** message.c *****/
  422. /*********************/
  423.  
  424. -- line 46 (near)
  425. #include "myTools.h"    /* Mizutori */
  426.  
  427.  
  428. -- line 1588 (near) in InsertText()
  429.              if (q - p + quoteStringLen > 80)
  430. #ifdef MZTR_PATCH    /* Mizutori */
  431.             {
  432.                 long pX, pEndX, qX;
  433.                 long addLen;
  434.                 pX = p - (unsigned char*)*newText; pEndX = pEnd - (unsigned char*)*newText; qX = q - (unsigned char*)*newText;
  435.                 addLen = Wrap(newText, p - (unsigned char*)*newText, q - (unsigned char*)*newText);
  436.                 p = (unsigned char*)*newText + pX; pEnd = (unsigned char*)*newText + pEndX; q = (unsigned char*)*newText + qX;
  437.                 q += addLen;
  438.                 pEnd += addLen;
  439.                 newLen += addLen;
  440.             }
  441. #else /* MZTR_PATCH */
  442.                 Wrap(newText, p - (unsigned char*)*newText, q - (unsigned char*)*newText);
  443. #endif /* MZTR_PATCH */
  444.  
  445.  
  446. -- line 4498 (near) in DoWrap()
  447. #ifdef MZTR_PATCH    /* Mizutori */
  448.     (**edit).selEnd += Wrap((**edit).hText, (**edit).selStart, (**edit).selEnd);
  449. #else /* MZTR_PATCH */
  450.     Wrap((**edit).hText, (**edit).selStart, (**edit).selEnd);
  451. #endif /* MZTR_PATCH */
  452.  
  453.  
  454. -- line 4533 (near) in DoUnwrap()
  455. #ifdef MZTR_PATCH    /* Mizutori */
  456.     (**edit).selEnd += UnWrap((**edit).hText, (**edit).selStart, (**edit).selEnd);
  457. #else /* MZTR_PATCH */
  458.     UnWrap((**edit).hText, (**edit).selStart, (**edit).selEnd);
  459. #endif /* MZTR_PATCH */
  460.  
  461.  
  462. /***** patch for Caret step by Arrow key *****/
  463.  
  464. /********************/
  465. /***** teutil.c *****/
  466. /********************/
  467.  
  468. -- line 19 (near)
  469. #include "myTools.h"    /* Mizutori */
  470.  
  471.  
  472. -- line 826 (near) in GetOffsetGivenPixelsFromBol()
  473.     while (result < eol && TextWidth(*hText, bol, result - bol) < pixelsFromBol) result++;
  474. #ifdef MZTR_PATCH    /* Mizutori */
  475.     if ( IsKanji(*hText+result-1,*hText+bol,*hText+eol) )  result++;
  476. #endif /* MZTR_PATCH */
  477.  
  478.  
  479. -- line 987 (near) in TEArrowKey()
  480. #ifdef MZTR_PATCH    /* Mizutori */
  481.                 if (shift || selStart == selEnd) { offset--;
  482.                     if ( IsKanji(*hText+offset-1,*hText,*hText+teLength) ) offset--; }
  483. #else /* MZTR_PATCH */
  484.                 if (shift || selStart == selEnd) offset--;
  485. #endif /* MZTR_PATCH */
  486.  
  487.  
  488. -- line 996 (near) in TEArrowKey()
  489. #ifdef MZTR_PATCH    /* Mizutori */
  490.                 if (shift || selStart == selEnd) { offset++;
  491.                     if ( IsKanji(*hText+offset-1,*hText,*hText+teLength) ) offset++; }
  492. #else /* MZTR_PATCH */
  493.                 if (shift || selStart == selEnd) offset++;
  494. #endif /* MZTR_PATCH */
  495.  
  496.  
  497.  
  498. /***** patch for Kill Custom MessageID *****/
  499.  
  500. /********************/
  501. /***** header.c *****/
  502. /********************/
  503.  
  504. -- line 25 (near)
  505. #include "myTools.h"    /* Mizutori */
  506.  
  507.  
  508. -- line 301 (near) in MakeMsgIdHeader()
  509.     sprintf(id, "<%.*s-%.2d%.2d%.2d%.2d%.2d%.2d%.4d@%s>",
  510.         len, gPrefs.emailAddress, dtRec.day, dtRec.month,
  511.         dtRec.year%100, dtRec.hour, dtRec.minute, dtRec.second, 
  512.         uniqueWithinSecond, hostName);
  513. #ifdef MZTR_PATCH    /* Mizutori */
  514.     if ( KillCustomMessageID() )  *id = 0;
  515. #endif /* MZTR_PATCH */
  516.     return noErr;
  517.  
  518. --
  519. mizutori@ai.rcast.u-tokyo.ac.jp
  520.